package threadDemo;

public class Demo5 {
    private volatile static int count = 0;

    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(() -> {
            while (count == 0) {

            }
            System.out.println("循环结束");
        });
        Thread t2 = new Thread(() -> {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            count = 1;
        });
        t1.start();
        t2.start();
        System.out.println("main 线程结束");
    }
}
